package com;

import lombok.extern.slf4j.Slf4j;

public class Main {

    public static void main(String[] args) {
        char[] cs = "luq".toCharArray();
        dialog(cs, 0);
    }

    public static void dialog(char[] cs, int pos) {
        if (pos == cs.length) {
            show(cs);
            return;
        }
        for (int i = pos; i < cs.length; i++) {
            swap(cs, pos, i);
            dialog(cs, pos + 1);
            swap(cs, pos, i);
        }
    }

    public static void show(char[] cs) {
        for (char c : cs) {
            System.out.print(c + " ");
        }
        System.out.println();
    }

    public static void swap(char[] cs, int n, int m) {
        char tmp = cs[n];
        cs[n] = cs[m];
        cs[m] = tmp;
    }

}
